package pro.shushi.pamirs.middleware.zookeeper.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Configuration;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Configuration
@ConfigurationProperties(prefix = ZKConfigurationConstant.PAMIRS_ZOOKEEPER_CONFIG_PREFIX)
@Validated
@RefreshScope
public class ZookeeperProperties {

    @NotBlank
    private String zkConnectString = "127.0.0.1:2181";

    @NotNull
    @Min(15000)
    private Integer zkSessionTimeout = 60000;

    @NotBlank
    private String rootPath = "/oinone";

    @NotNull
    private String username = "";

    @NotNull
    private String password = "";

    public String getZkConnectString() {
        return zkConnectString;
    }

    public void setZkConnectString(String zkConnectString) {
        this.zkConnectString = zkConnectString;
    }

    public Integer getZkSessionTimeout() {
        return zkSessionTimeout;
    }

    public void setZkSessionTimeout(Integer zkSessionTimeout) {
        this.zkSessionTimeout = zkSessionTimeout;
    }

    public String getRootPath() {
        return rootPath;
    }

    public void setRootPath(String rootPath) {
        this.rootPath = rootPath;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }
}
